<?php
	session_start(); 
	//include_once("ldap_config.inc.php" );
	include('DAOUser.php');
	$iLoginValido = 0;
	
	if(isset($_POST['user']) && isset($_POST['pass'])){
		$sUser = trim($_POST['user']);
		$sPass = trim($_POST['pass']);
		
		if(count($sUser) < 1)
			$bLoginValido += 1;
		if(count($sPass) < 1)
			$bLoginValido += 2;
		
		if( $iLoginValido != 0)
			header("Location: ../index.php?error=".$iLoginValido);
		
		$oDaoUser = new DAOUser;
		//if(ldaph_auth_b($sUser,$sPass)){
			if($oDaoUser->existUser($sUser)){
				$_SESSION['admitido'] = true;
				$_SESSION['oUsuario'] = serialize($oDaoUser);
				header("Location: listaSalas.php");
			}else{
				$_SESSION['admitido'] = false;
				header("Location: ../index.php?error=4"); 	
			}
		/*}
		else{
			header("Location: ../index.php");}*/	
	}else{
		header("Location: ../index.php");	
	}
	
?>
